/*
* Copyright (C) 2020 ~ 2024 chaigec All Rights Reserved.
*
* Author:     chaigec <chaigec@163.com>
* Maintainer: chaigec <chaigec@163.com>

 * Use of this source code is governed by MIT license that can be found in the
 * LICENSE file in the root of the source tree. All contributing project authors
 * may be found in the AUTHORS file in the root of the source tree.
*/

#include "MkSipListener.h"
#include "MkUtil/MkUtil.h"

CMkSipListener::CMkSipListener(CMkSipServer* pParent)
    : m_pParent(pParent)
{

}

Uint32 CMkSipListener::Start(const MkString& ListenHost, Uint16 ListenPort, const MkString& PublicHost, Uint16 PublicPort)
{
    m_ListenHost = ListenHost;
    m_ListenPort = ListenPort;
    if (ListenHost.empty()
        || 0 == inet_addr(ListenHost.c_str())) {
        CMkUtil::GetLocalIp(m_ListenHost);
    }
    m_PublicPort = PublicPort;
    m_PublicHost = PublicHost;
    if (0 == m_PublicPort) {
        m_PublicPort = m_ListenPort;
    }
    if (m_PublicHost.empty()
        || 0 == inet_addr(m_PublicHost.c_str())) {
        m_PublicHost = m_ListenHost;
    }
    return NoneError;
}

CMkSipListener::~CMkSipListener()
{

}
